<?php

namespace app\backend\controller;

use app\common\model\User as userModel;
use app\common\model\IntegralLog ;
use app\common\model\UserLevel;
use app\common\model\WalletLog ;
use app\common\model\Margin;
use think\Controller;
use think\Request;
use app\common\model\Money;
class Recharge extends Controller
{   
    //积分记录
    public function integral()
    {
        return $this->fetch();
    }
    public function integralList()
    {
        $limit = request()->param('limit');
        $nickname = request()->param('nickname');
        if($nickname){
            $user_list=IntegralLog::where('userid',$nickname)->order('id desc')->paginate($limit);
            $count = IntegralLog::where('userid',$nickname)->count();
        }else{
            $user_list = IntegralLog::order('id desc')->paginate($limit);
            $count = IntegralLog::count();
        }
        if ($user_list) {
            $data = ['code' => 0, 'msg' => '用户列表', 'count' => $count, 'data' => $user_list->items()];
            return json($data);
        } else {
            $data = ['code' => 0, 'msg' => '用户列表', 'count' => $count, 'data' => array()];
            return json($data);
        }

    }
    //余额记录
    public function wallet()
    {
        return $this->fetch();
    }
    public function walletList()
    {
        $limit = request()->param('limit');
        $nickname = request()->param('nickname');
        if($nickname){
            $user_list=WalletLog::where('userid',$nickname)->order('id desc')->paginate($limit);
            $count = WalletLog::where('userid',$nickname)->count();
        }else{
            $user_list = WalletLog::order('id desc')->paginate($limit);
            $count = WalletLog::count();
        }
        if ($user_list) {
            $data = ['code' => 0, 'msg' => '用户列表', 'count' => $count, 'data' => $user_list->items()];
            return json($data);
        } else {
            $data = ['code' => 0, 'msg' => '用户列表', 'count' => $count, 'data' => array()];
            return json($data);
        }

    }


}
